package com.atguigu;


import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/serverlt5")
public class serverlt5 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.请求行
        String method = req.getMethod();
        System.out.println(method);
        String scheme = req.getScheme();
        System.out.println(scheme);
        String protocol = req.getProtocol();
        System.out.println(protocol);
        int localPort = req.getLocalPort();
        System.out.println(localPort);
        int remotePort = req.getRemotePort();
        System.out.println(remotePort);
        int serverPort = req.getServerPort();
        System.out.println(serverPort);
        System.out.println("请求行");
        Enumeration<String> parameterNames = req.getHeaderNames();
        while(parameterNames.hasMoreElements()){
            String s = parameterNames.nextElement();
            System.out.println(s+" = "+req.getHeader(s));
        }
        StringBuffer requestURL = req.getRequestURL();
        System.out.println(requestURL);
        String requestURI = req.getRequestURI();
        System.out.println(requestURI);
    }
}
